package com.pan.controller;


import com.pan.entity.Result;
import com.pan.service.SeckillCouponService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
public class SeckillCouponController {

    @Resource
    private SeckillCouponService seckillCouponService;


    @PostMapping("/seckill/coupon")
    @ResponseBody
    public Result seckillCoupon(@CookieValue("userTicket") String userTicket,
                                @RequestParam("couponId") Long couponId){
        Result result = seckillCouponService.seckillCoupon(userTicket,couponId);
        return result;
    }

    @GetMapping("/seckill/get/countAndLimit")
    @ResponseBody
    public Result<Integer> getCouponCount(@RequestParam("couponId") Long couponId){
        Result<Integer> result = seckillCouponService.getCount(couponId);
        return result;
    }

}
